package xainchenggaoji;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author Mr.ma
 * @since 2022/11/2 21:54
 * 使用ThreadPoolExecutor创建线程池
 **/
public class CreatePool02 {
    public static void main(String[] args) {
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(2,5,10,
                TimeUnit.SECONDS,new LinkedBlockingQueue(4));
        for (int i = 0; i < 20; i++) {
            final int j = i;
            threadPoolExecutor.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName() + "====" + j);
                }
            });
        }
    }
}
